package com.example.liujinliang.broadcastbestpractice.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.liujinliang.broadcastbestpractice.R;

public class LoginActivity extends BaseActivity{

    private EditText accountEdit;

    private EditText pwdEdit;

    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        // 初始化成员变量
        accountEdit = (EditText) findViewById(R.id.login_account);
        pwdEdit = (EditText) findViewById(R.id.login_pwd);
        button = (Button) findViewById(R.id.login_btn);

        // 校验登录权限
        button.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {

                String account = accountEdit.getText().toString();
                String pwd = pwdEdit.getText().toString();
                if (account.equals("gene") && pwd.equals("%TGBnji9")) {
                    Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    Toast.makeText(LoginActivity.this, "account or password is invalid", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }


}
